/**
 * 武汉天瑞兴科技有限公司
 */
package com.adds.lvds.security.acegi;

import java.io.IOException;
import java.util.Collection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

/**
 *项目名称 ：lvds-web-security
 *@author zhangjian
 *@time 2016-8-12上午11:30:22
 */
@SuppressWarnings("all")
public class LoginAuthenticationSuccesssHandler implements
AuthenticationSuccessHandler{
	private String defaultUrl;
	public void setDefaultUrl(String defaultUrl) {
		this.defaultUrl = defaultUrl;
	}
	
	@Override
	public void onAuthenticationSuccess(HttpServletRequest request,
			HttpServletResponse response, Authentication arg2) throws IOException,
			ServletException {
		Collection<GrantedAuthority> authorities=(Collection<GrantedAuthority>) arg2.getAuthorities();
		Object[] object=authorities.toArray();
		response.sendRedirect(request.getContextPath()+defaultUrl);
	}

}
